package language

import (
	"gddgame.cc/galaxy/common/dsl/game"
	"gddgame.cc/galaxy/utils"
)

//go:generate msgp

//msgp:tuple LanguageInstance
type LanguageInstance struct {
	Key string `json:"string" msg:"string"`

	*game.DataExtend `json:"-" msg:"-"`
}

func NewLanguage(provider *game.DataProvider, language *SettingLanguage) *LanguageInstance {
	key := language.Key
	if key == "" {
		key = utils.ToString(language.Id)
	}
	extend := game.NewDataExtend(key, language.UpdateTime).Bind(language.Content)
	lang := &LanguageInstance{
		Key: key,

		DataExtend: extend,
	}
	return lang
}
